#!/bin/bash
cd `dirname $0`

cd ..

echo "==============================清除缓存===================================== "
echo 3 > /proc/sys/vm/drop_caches
echo "==============================清除缓存===================================== "

echo "==============================git---pull===================================== "
git pull
echo "==============================git---pull===================================== "


echo "==============================mvn===================================== "
mvn clean
mvn package
echo "==============================mvn===================================== "



jar_file=sparrow-0.0.1-SNAPSHOT.jar
serverpath=/root/springboot
day=`date +%Y%m%d%H%M`

if [[ ! -d ${serverpath}/bak ]]; then
  mkdir ${serverpath}/bak
fi

echo "备份中。。。。。。"
cp /root/git_hub/sparrow/target/${jar_file} /root/springboot/bak/${day}_${jar_file}

pid=`ps aux | grep  ${serverpath}/${jar_file} |grep -v grep | awk '{print $2}'`
echo ${pid}
kill -9 $pid

#cp jar to serverpath
rm -rf ${serverpath}/${jar_file}
cp /root/git_hub/sparrow/target/${jar_file} ${serverpath}

nohup java -Xms64m -Xmx128m -jar  ${serverpath}/${jar_file} > nohup.out 2>&1 &
